package factory;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * 读取线程下的class文件
 */
public class BeanName {
    private static String classPath="E:"+File.separator+"Rong"+File.separator+"target"+File.separator+"classes";
    private static List<String> list=new ArrayList<String>();
    public static List<String> init(){
        getPath(classPath);
        return list;
    }
    //获取线程下的所有文件名
    private static void getPath(String path){
        File fis=new File(path);
        File[] files = fis.listFiles();
        if(files!=null){
            for(File fi:files){
                if(fi.isFile()){
                    String paths = fi.getAbsolutePath();
                    String ph=subStr(paths);
                    if(!ph.equals("util.DBUtil")){
                        list.add(ph);
                    }
                }else{
                    getPath(fi.getPath());
                }
            }
        }
    };
    //截取字符串
    private static String subStr(String paths){
        String substring = paths.substring(classPath.length()+1, paths.length()).replace(".class","").replace(File.separator,".");
        return substring;
    }
}
